# -*- coding: utf-8 -*-
from django.db import models
#from django.db.models import permalink
from django.contrib.auth.models import User
from django.utils.encoding import smart_str, smart_unicode

class Post(models.Model):
    title = models.CharField('标题', max_length=35)
    content = models.TextField('正文', ) 

    author = models.ForeignKey(User)   
    
    commentcount = models.IntegerField('评论数量', default=0)

    createdtime = models.DateTimeField(auto_now_add = True,db_index=True)   #auto_now_add = True, 
    replytime = models.DateTimeField(auto_now = True, db_index=True) 
    
    class Meta:
        ordering = ['-replytime']
        
    #@permalink
    def get_absolute_url(self):
        return "/post/%s/" % self.id
    
    def __unicode__(self):   
        return smart_unicode(self.title)

class xxx(models.Model):
    content = models.TextField('回复',) 


